package Demo05;

import javax.swing.*;

/*
用户注册
 */
public class UserRegister extends JFrame {
    private  JPanel mainPanel;//主面板
    //标签
    private  JLabel lblNo,lblName,lblSex,lblAge,lblCls,lblHobby,lblNote;
    //单行文本框；
    private  JTextField txtNO,txtName,txtAge;
    //单选按钮；-----作成一个按钮组
    private  JRadioButton rdoSexMan,rdoSexWoman;
    //作一个级和按钮组
    private  ButtonGroup bg;
    //下拉
    private  JComboBox<String> cboCls;
    //浮选框；
    private  JCheckBox cboNetwork,cboGame,cboBall,cboBuy;
    //多行文本框；
    private  JTextArea textNote;
    //作一个划块；滚动面板
    private  JScrollPane scoNote;

    //定义按钮 ；注册 ，退出
    private  JButton btnReg,btnExit;


    //构造方法
    public  UserRegister(){
        //实例化控件
        mainPanel=new JPanel(null);
        lblNo=new JLabel("学号");
        lblName=new JLabel("姓名");
        lblSex=new JLabel("性别");
        lblAge=new JLabel("年龄");
        lblCls=new JLabel("班级");
        lblHobby=new JLabel("爱好");
        lblNote=new JLabel("个人简介");

        txtNO=new JTextField();
        txtName=new JTextField();
        txtAge=new JTextField();

        rdoSexMan=new JRadioButton("男");
        rdoSexWoman=new JRadioButton("女");
        bg=new ButtonGroup();

        String[] cls={"软件18-1","软件19-1","软件19-2","软件19-3","软件19-4","软件19-5","软件19-6",};
        cboCls=new JComboBox<String>(cls);

//        cboBall=new JCheckBox("篮球");
//        cboBall=new JCheckBox("足球");
//        cboBall=new JCheckBox("上网");
//        cboBall=new JCheckBox("购物");
//        cboBall=new JCheckBox("游泳");
//        cboBall=new JCheckBox("buibui");


        cboBall=new JCheckBox("篮球");
        cboBuy=new JCheckBox("购物");
        cboGame=new JCheckBox("游戏");
        cboNetwork=new JCheckBox("上网");

        textNote=new JTextArea();
        scoNote=new JScrollPane(textNote);


        btnReg=new JButton("注册");
        btnExit=new JButton("退出");

        //设置控件位置大小 ‘
        lblNo.setBounds(30,30,60,25);
        txtNO.setBounds(90,30,150,25);

        lblName.setBounds(30,65,60,25);
        txtName.setBounds(90,65,150,25);

        lblAge.setBounds(30,100,60,25);
        txtAge.setBounds(90,100,150,25);

        lblSex.setBounds(30,135,60,25);
        rdoSexMan.setBounds(90,135,60,25);
        rdoSexWoman.setBounds(180,135,60,25);
        bg.add(rdoSexMan);
        bg.add(rdoSexWoman);//

        lblCls.setBounds(30,170,60,25);
        cboCls.setBounds(90,170,150,25);

        lblHobby.setBounds(30,205,60,25);
        cboBall.setBounds(900,205,60,25);
        cboBall.setBounds(150,205,60,25);
        cboBall.setBounds(210,205,60,25);
        cboBall.setBounds(270,205,60,25);
//        cboBall.setBounds(330,205,60,25);

//        cboNetwork.setBounds(30);

        lblNote.setBounds(30,240,60,25);
        scoNote.setBounds(90,240,150,100);

        btnReg.setBounds(90,360,60,25);
        btnExit.setBounds(180,360,60,25);

        this.setBounds(100,100,360,4300);




        //将按钮放入容器；
        //铺面板到窗口
//        setContentPane(mainPanel);
//        mainPanel.add(lblName);
//        mainPanel.add(lblNo);
//        mainPanel.add(lblNote);
//        mainPanel.add(lblCls);
//        mainPanel.add(lblAge);
//        mainPanel.add(lblHobby);
//        mainPanel.add(lblSex);
//        mainPanel.add(txtName);
//        mainPanel.add(txtAge);
//        mainPanel.add(txtNO);
//        mainPanel.add(scoNote);
//        mainPanel.add(rdoSexMan);
//        mainPanel.add(rdoSexWoman);
//        mainPanel.add(rdoSexWoman);
//        mainPanel.add(cboBall);
////        mainPanel.add(cboBuy);
//        mainPanel.add(cboCls);
//        mainPanel.add(cboGame);
//        mainPanel.add(cboNetwork);
////        mainPanel.add(c);

        setContentPane(mainPanel);
        mainPanel.add(lblAge);
        mainPanel.add(lblCls);
        mainPanel.add(lblHobby);
        mainPanel.add(lblName);
        mainPanel.add(lblNo);
        mainPanel.add(lblNote);
        mainPanel.add(lblSex);
        mainPanel.add(txtAge);
        mainPanel.add(txtName);
        mainPanel.add(txtNO);
        mainPanel.add(scoNote);
        mainPanel.add(rdoSexMan);
        mainPanel.add(rdoSexWoman);
        mainPanel.add(cboCls);
        mainPanel.add(cboBall);
        mainPanel.add(cboBuy);
        mainPanel.add(cboGame);
        mainPanel.add(cboNetwork);

        mainPanel.add(btnReg);
        mainPanel.add(btnExit);


        //设置窗口属性
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setResizable(false);
    }

    public static void main(String[] args) {
        new UserRegister();
    }


}
